<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加角色|<{$configcache['Title']}></title>
<link rel="stylesheet" type="text/css" href="__CSS__/content.css"  />
<link rel="stylesheet" type="text/css" href="__CSS__/public.css"  />
<script type="text/javascript" src="__JS__/jquery.js"></script>
<script type="text/javascript" src="__JS__/Public.js"></script>
<script type="text/javascript" src="__JS__/winpop.js"></script>
<script type="text/javascript" src="__JS__/check.js"></script>
<script>
$(document).ready(function() {
	$('.button').click(function() {
		var rolename=$('#dl dd .qtext').val();
		var description=$('#dl dd .textarea').val();
		var status=$('#dl dd .status:checked').val();
		var comp='';
		for (i=0; i<$('#dl dd .comp').size(); i++) {
			if (!$('#dl dd .comp').eq(i).attr('checked')==false) {
				comp=comp+$('#dl dd .comp').eq(i).val()+',';
			}
		}
		
		if (!tcheck(rolename,'','请填写角色名称')) { return false; }
		if (!tcheck(rolename,'2,20','角色名称请在20个字符以内','length')) { return false; }
		if (!tcheck(description,'0,30','描述请在30个字符以内','length')) { return false; }
		if (!tcheck(comp,'','给用户授点权吧')) { return false; }
		
		wintq('正在添加，请稍后...',4,20000,0,'');
		$.ajax({
			url:'__CONTROLLER__/roleadd_do',
			dataType:'json',
			type:'POST',
			data:'rolename='+rolename+'&description='+description+'&comp='+comp+'&status='+status,
			success: function(data) {
				if (data.s=='ok') {
					wintq('添加成功',1,1500,0,'__CONTROLLER__/roleadd');
				}else {
					wintq(data.s,3,1500,10,'');
				}
			}
		});
	});
});
</script>
</head>
<body>
<div id="content">
	<dl id="dl">
    	<dt>添加控制角色</dt>
        <dd>
        	<span class="dd_left">角色名称：</span>
        	<span class="dd_right"><input type="text" name="rolename" class="qtext" maxlength="20" /><font>* 输入如：来宾用户</font></span>
        </dd>
        <dd>
        	<span class="dd_left">角色说明：</span>
            <span class="dd_right"><textarea name="description" class="textarea"></textarea></span>
        </dd>
        <dt>权限分配</dt>
        <volist name="volist" id="vo">
        <dd>
        	<span class="dd_left"><{$vo.cname}>：</span>
            <span class="dd_right" style="width:590px;">
            	<volist name="slist" id="s">
                <if condition="$s.sid eq $vo['id']">
                <label><input type="checkbox" class="comp" value="<{$s.id}>" /> <{$s.cname}></label>
                </if>
                </volist>
            </span>
        </dd>
        </volist>
        <dd>
        	<span class="dd_left">状态：</span>
            <span class="dd_right"><label><input type="radio" name="status" class="status" value="0" checked /> 正常</label><label><input type="radio" name="status" class="status" value="1" /> 锁定</label></span>
        </dd>
        <dd><input type="button" class="button" value="提 交" /></dd>
    </dl>
</div>
</body>
</html>
